import {
    queryOrders, deleteOrderById, copyOrderById, getOrderById, queryProducts, queryDrawers,
    queryLinkmans, queryAddresses, queryBuyers, updateOrder, createLinkman, createAddress,
    cancelOrderById, confirmLetterById, querySupplyGoods, queryOrderCost, deleteOrderCost,
    applyOrderCost, confirmCost, addOrderCost, createOrder, queryTgManagers, copyProductById,
    getOrderCurrency2USDRate, queryOrderByNo, cancelChargeConfirm
} from "../../services/order/orderManage";
import { returnOrder } from "../../services/order/declareApproval";
import Constants from '../../utils/Constants';
import { message } from "antd";
import { getRecinvoicesList } from "../../services/drawback/recinvoices";
import { inoviceheader, inoviceproducts } from "../../services/drawback/invoice";
const productAddTempIdPrefix = "productAddTempIdPrefix_";
const R = require('ramda');
export default {
    namespace: 'orderManage',
    state: {
        page: {
            page: 1,
            size: 10,
            totalRow: 0,
            totalPage: 0
        },
        productPage: {
            page: 1,
            size: 10,
            totalRow: 0,
            totalPage: 0
        },
        costPage: {
            page: 1,
            size: 10,
            totalRow: 0,
            totalPage: 0
        },
        list: [],
        allproducts: [],
        supplyGoodsList: [],
        drawerList: [],
        linkmanList: [],
        addressList: [],
        buyerList: [],
        costList: [],
        orderQueryList: [],
        dataSource: {},
        customer: {},
        goodsAddress: {},
        linkMan: {},
        buyer: {},
        settlement: {},
        tradeCountry: {},
        countryCD: {},
        placeClearance: {},
        orderCharges: {},
        kindPackage: {},
        lesseeInfo: {},
        supervision: {},
        natureExemption: {},
        priceItem: {},
        orderTgApproval: {},
        tgManagerList: {},
        usdRate: null, //当前订单币种转美金的汇率，用于计算开票人的限额
        statistics: []
    },
    reducers: {
        /**
         * 设置数据列表
         *
         * @param state
         * @param action
         */

        setInoviceheader(state, action) {
            let payload = action.payload;
            return { ...state, inoviceheader: payload.inoviceheader };
        },

        setInoviceproductsList(state, { payload }) {
            return { ...state, inoviceproductsList: payload.list }
        },


        setOrderManageList(state, { payload }) {
            return { ...state, list: payload.list, page: payload.page, status: payload.status }
        },

        setOrderQueryList(state, { payload }) {
            return { ...state, orderQueryList: payload.orderQueryList }
        },
        /**
         * 设置产品数据列表
         *
         * @param state
         * @param action
         */
        setProductList(state, { payload }) {
            return { ...state, allproducts: payload.productList, productPage: payload.productPage }
        },
        /**
         * 设置费用列表
         *
         * @param state
         * @param action
         */
        setCostList(state, { payload }) {
            return { ...state, costList: payload.costList, costPage: payload.costPage }
        },
        /**
         * 设置开票人数据列表
         *
         * @param state
         * @param action
         */
        setDrawerList(state, { payload }) {
            return { ...state, drawerList: payload.drawerList }
        },
        /**
         * 设置联系人数据列表
         *
         * @param state
         * @param action
         */
        setLinkmanList(state, { payload }) {
            return { ...state, linkmanList: payload.linkmanList }
        },
        /**
         * 设置境内货源地列表
         *
         * @param state
         * @param action
         */
        setSupplyGoodsList(state, { payload }) {
            return { ...state, supplyGoodsList: payload.supplyGoodsList }
        },
        /**
         * 设置货物存放地址数据列表
         *
         * @param state
         * @param action
         */
        setAddressList(state, { payload }) {
            return { ...state, addressList: payload.addressList }
        },
        /**
         * 设置货物存放地址数据列表
         *
         * @param state
         * @param action
         */
        setBuyerList(state, { payload }) {
            return { ...state, buyerList: payload.buyerList }
        },

        /**
         * 清理缓存的订单，防止新增订单的时候打开页面就有数据
         *
         * @param state
         * @param action
         * @returns {{showStatus: (boolean|*)}}
         */
        cleanOrder(state, action) {
            return { ...state, dataSource: { cstid: action.payload.cstid } }
        },
        /**
         * 新增订单时由于要用到客户的数据比如自营还是外综的字段，查询客户信息成功后设值到订单state的customer
         *
         * @param state
         * @param action
         * @returns {{showStatus: (boolean|*)}}
         */
        setCustomer(state, action) {
            return { ...state, customer: action.payload.customer }
        },
        /**
         * 设置通关专员列表
         *
         * @param state
         * @param action
         */
        setTgManagerList(state, { payload }) {
            return { ...state, tgManagerList: payload.tgManagerList }
        },

        refreshState(state, { payload }) {
            return { ...state, ...payload }
        }
    },
    effects: {
        /**
         * 分页查询订单
         *
         * @param call
         * @param put
         * @param select
         */
        *queryOrderManageList({ payload }, { call, put, select }) {
            let page = yield select(state => state.orderManage.page);
            page = R.isNil(payload) || R.isNil(payload.page) ? page : payload.page;
            const res = yield call(queryOrders, {
                applyFlag: false,
                cstId: R.isNil(payload) || R.isNil(payload.cstId) ? "" : payload.cstId,
                cstName: R.isNil(payload) || R.isNil(payload.cstName) ? "" : payload.cstName,
                orderNo: R.isNil(payload) || R.isNil(payload.orderNo) ? "" : payload.orderNo,
                contractNo: R.isNil(payload) || R.isNil(payload.contractNo) ? "" : payload.contractNo,
                declarationType: R.isNil(payload) || R.isNil(payload.declarationType) ? "" : payload.declarationType,
                status: R.isNil(payload) || R.isNil(payload.status) ? "" : payload.status,
                beginTime: payload.beginTime,
                endTime: payload.endTime,
                page: page
            })
            if (res.data.resultCode === "ok") {
                let content = res.data.content;
                let list = R.isNil(content.list) ? [] : content.list;
                yield put({
                    type: 'refreshState',
                    payload: {
                        status: R.isNil(payload) || R.isNil(payload.status) ? "" : payload.status,
                        list: list,
                        statistics: content.statistics ? content.statistics : [],
                        page: R.isNil(content.page) ? Constants.DEFAULTPAGE : content.page
                    }
                });
            } else {
                message.error(res.data.errMessage);
            }
        },

        /**
         * 查询订单信息列表
         *
         * @param orderNo
         * @param contractNo
         * @return
         */
        *queryOrderByNo({ payload }, { call, put, select }) {
            // let page = yield select(state => state.orderManage.page);
            // page = R.isNil(payload) || R.isNil(payload.page) ? page : payload.page;
            const res = yield call(queryOrderByNo, {
                // applyFlag: false,
                // cstId: R.isNil(payload) || R.isNil(payload.cstId) ? "" : payload.cstId,
                // cstName: R.isNil(payload) || R.isNil(payload.cstName) ? "" : payload.cstName,
                orderNo: R.isNil(payload) || R.isNil(payload.orderNo) ? "" : payload.orderNo,
                contractNo: R.isNil(payload) || R.isNil(payload.contractNo) ? "" : payload.contractNo,
                // declarationType: R.isNil(payload) || R.isNil(payload.declarationType) ? "" : payload.declarationType,
                // status: R.isNil(payload) || R.isNil(payload.status) ? "" : payload.status,
                // page: page
            })
            if (res.data.resultCode === "ok") {
                let content = res.data.content;
                let list = R.isNil(content.list) ? [] : content.list;
                yield put({
                    type: 'setOrderQueryList',
                    payload: {
                        // status: R.isNil(payload) || R.isNil(payload.status) ? "" : payload.status,
                        orderQueryList: list,
                        // page: R.isNil(content.page) ? Constants.DEFAULTPAGE : content.page
                    }
                });
            } else {
                message.error(res.data.errMessage);
            }
        },

        /**
         *
         * @param payload
         * @param call
         * @param put
         * @param select
         */
        *getInoviceheaderByOrderId({ payload }, { call, put, select }) {
            const res = yield call(inoviceheader, { orderId: payload.orderId });

            if (res.data.resultCode === "ok") {
                let data = res.data.content;
                yield put({
                    type: "setInoviceheader",
                    payload: {
                        inoviceheader: data
                    }
                });
            } else {
                message.error(res.data.errMessage);
            }

        },
        /**
         *
         * @param payload
         * @param call
         * @param put
         * @param select
         */
        *getInoviceproductsByOrderId({ payload }, { call, put, select }) {
            const res = yield call(inoviceproducts, { orderId: payload.orderId });

            if (res.data.resultCode === "ok") {
                let data = res.data.content;

                yield put({
                    type: "setInoviceproductsList",
                    payload: {
                        list: data
                    }
                });
            } else {
                message.error(res.data.errMessage);
            }

        },

        /**
         * 分页查询产品
         *
         * @param call
         * @param put
         * @param select
         */
        *queryProductList({ payload }, { call, put, select }) {
            const res = yield call(queryProducts, { cstId: payload.cstId, productName: payload.productName, status: "4", productPage: payload.productPage });
            if (res.data.resultCode === "ok") {
                let content = res.data.content;
                let productList = R.isNil(content.list) ? [] : content.list;
                yield put({
                    type: 'setProductList',
                    payload: {
                        productList: productList,
                        productPage: R.isNil(content.page) ? Constants.DEFAULTPAGE : content.page
                    }
                });
            } else {
                message.error(res.data.errMessage);
            }
        },

        /**
         *
         * 复制产品
         * @param payload
         * @param call
         * @param put
         * @param select
         *
         */
        *copyProudctById({ payload }, { call, put, select }) {
            const res = yield call(copyProductById, { id: payload.id });
            if (res.data.resultCode === "ok") {
                message.info("复制成功！");
                yield put({
                    type: "setProductList",
                    payload: R.isNil(payload.searchConditions) ? {} : payload.searchConditions
                });
            } else {
                message.error(res.data.errMessage)
            }
        },

        /**
         * 查询开票人下拉列表
         *
         * @param call
         * @param put
         * @param select
         */
        *queryDrawerList({ payload }, { call, put, select }) {
            const res = yield call(queryDrawers, { cstId: payload.cstId, status: "4" });
            if (res.data.resultCode === "ok") {
                let content = res.data.content;
                yield put({
                    type: 'setDrawerList',
                    payload: {
                        drawerList: R.isNil(content) ? [] : content,
                    }
                });
            } else {
                message.error(res.data.errMessage);
            }
        },

        /**
         * 查询联系人
         *
         * @param call
         * @param put
         * @param select
         */
        *queryLinkmanList({ payload }, { call, put, select }) {
            const res = yield call(queryLinkmans, { cstId: payload.cstId/*, status: "1"*/ });
            if (res.data.resultCode === "ok") {
                let content = res.data.content;
                yield put({
                    type: 'setLinkmanList',
                    payload: {
                        linkmanList: R.isNil(content) ? [] : content,
                    }
                });
            } else {
                message.error(res.data.errMessage);
            }
        },

        /**
         * 查询货物存放地址
         *
         * @param call
         * @param put
         * @param select
         */
        *queryAddressList({ payload }, { call, put, select }) {
            const res = yield call(queryAddresses, { cstId: payload.cstId/*, status: "1"*/ });
            if (res.data.resultCode === "ok") {
                let content = res.data.content;
                yield put({
                    type: 'setAddressList',
                    payload: {
                        addressList: R.isNil(content) ? [] : content,
                    }
                });
            } else {
                message.error(res.data.errMessage);
            }
        },
        /**
         * 查询境外买家下拉
         *
         * @param call
         * @param put
         * @param select
         */
        *queryBuyerList({ payload }, { call, put, select }) {
            const res = yield call(queryBuyers, { cstId: payload.cstId/*, status: "1"*/ });
            if (res.data.resultCode === "ok") {
                let content = res.data.content;
                yield put({
                    type: 'setBuyerList',
                    payload: {
                        buyerList: R.isNil(content) ? [] : content,
                    }
                });
            } else {
                message.error(res.data.errMessage);
            }
        },

        /**
         * 根据客户查询订单境内货源地
         *
         * @param call
         * @param put
         * @param select
         */
        *querySupplyGoods({ payload }, { call, put, select }) {
            const res = yield call(querySupplyGoods, { cstId: payload.cstId });
            if (res.data.resultCode === "ok") {
                let content = res.data.content;
                yield put({
                    type: 'setSupplyGoodsList',
                    payload: {
                        supplyGoodsList: R.isNil(content) ? [] : content,
                    }
                });
            } else {
                message.error(res.data.errMessage);
            }
        },

        /**
         * 删除订单
         * @param payload
         * @param call
         * @param put
         * @param select
         */
        *deleteOrderById({ payload }, { call, put, select }) {
            const res = yield call(deleteOrderById, { id: payload.id });
            if (res.data.resultCode === "ok") {
                message.info("删除成功！");

                yield put({
                    type: "queryOrderManageList",
                    payload: R.isNil(payload.searchConditions) ? {} : payload.searchConditions
                });
            } else {
                message.error(res.data.errMessage);
            }
        },
        /**
         * 终止订单/取消订单
         * @param payload
         * @param call
         * @param put
         * @param select
         */
        *cancelOrderById({ payload }, { call, put, select }) {
            const res = yield call(cancelOrderById, { id: payload.id });
            if (res.data.resultCode === "ok") {
                message.info("终止成功！");
                yield put({
                    type: "queryOrderManageList",
                    payload: R.isNil(payload.searchConditions) ? {} : payload.searchConditions
                });
            } else {
                message.error(res.data.errMessage);
            }

        },

        /**
         * 复制订单
         * @param payload
         * @param call
         * @param put
         * @param select
         */
        *copyOrderById({ payload }, { call, put, select }) {
            const res = yield call(copyOrderById, { id: payload.id });
            if (res.data.resultCode === "ok") {
                message.info("复制成功！");
                yield put({
                    type: "queryOrderManageList",
                    payload: R.isNil(payload.searchConditions) ? {} : payload.searchConditions
                });
            } else {
                message.error(res.data.errMessage);
            }

        },


        /**
         * 根据id获取订单详情
         * @param payload
         * @param call
         * @param put
         * @param select
         */
        *getOrderById({ payload }, { call, put, select }) {
            const res = yield call(getOrderById, { id: payload.id });
            if (res.data.resultCode === "ok") {
                let data = res.data.content;
                let order = data.order;
                let orderProductDetails = R.isNil(data.orderProductDetails) || R.isEmpty(data.orderProductDetails) ? [] : data.orderProductDetails;
                R.map((row) => { row.key = row.id }, orderProductDetails);
                order.orderProductDetails = orderProductDetails;
                order.orderTgApproval = R.isNil(data.orderTgApproval) ? {} : data.orderTgApproval;
                //模拟创建的代码 start
                /*                 data = {};
                                order = {cstid: 1}; */
                //模拟创建代码 end
                yield put({
                    type: "refreshState",
                    payload: {
                        dataSource: order,
                        destPort:R.isNil(data.destPort) ? {} : data.destPort,
                        customer: R.isNil(data.customer) ? {} : data.customer,
                        goodsAddress: R.isNil(data.goodsAddress) ? {} : data.goodsAddress,
                        linkMan: R.isNil(data.linkMan) ? {} : data.linkMan,
                        buyer: R.isNil(data.buyer) ? {} : data.buyer,
                        settlement: R.isNil(data.settlement) ? {} : data.settlement,
                        tradeCountry: R.isNil(data.tradeCountry) ? {} : data.tradeCountry,
                        countryCD: R.isNil(data.countryCD) ? {} : data.countryCD,
                        placeClearance: R.isNil(data.placeClearance) ? {} : data.placeClearance,
                        orderCharges: R.isNil(data.orderCharges) ? [] : data.orderCharges,
                        kindPackage: R.isNil(data.kindPackage) ? {} : data.kindPackage,
                        lesseeInfo: R.isNil(data.lesseeInfo) ? {} : data.lesseeInfo,

                        supervision: R.isNil(data.supervision) ? {} : data.supervision,
                        natureExemption: R.isNil(data.natureExemption) ? {} : data.natureExemption,
                        priceItem: R.isNil(data.priceItem) ? {} : data.priceItem,
                        orderTgApproval: R.isNil(data.orderTgApproval) ? {} : data.orderTgApproval,
                        declaration: data.declaration ? data.declaration : {}
                    }
                });
            } else {
                message.error(res.data.errMessage);
            }

        },

        /**
         * 更新订单
         * @param payload
         * @param call
         * @param put
         * @param select
         */
        *updateOrder({ payload }, { call, put, select }) {
            const dataSource = payload.dataSource;
            let orderProductDetails = [];
            R.map((product) => {
                let temp = R.omit(['key', 'createtime', 'creator', 'status', 'updater', 'updatetime', 'productbranchname'])(product);
                if (R.contains(productAddTempIdPrefix)(temp.id)) {
                    temp.id = "";//去掉新增临时定义的id
                }
                orderProductDetails = R.concat(orderProductDetails, [temp]);
            }, R.isNil(dataSource.orderProductDetails) ? [] : dataSource.orderProductDetails)//去掉key
            dataSource.orderProductDetails = orderProductDetails;
            const res = yield call(updateOrder, { order: dataSource });
            if (res.data.resultCode === "ok") {
                message.info("订单修改成功！");
                if (payload.onSuccess) payload.onSuccess();
            } else {
                message.error(res.data.errMessage);
                if (payload.onFail) payload.onFail();
            }
        },

        /**
         * 创建订单
         * @param payload
         * @param call
         * @param put
         * @param select
         */
        *createOrder({ payload }, { call, put, select }) {
            const dataSource = payload.dataSource;
            let orderProductDetails = [];
            R.map((product) => {
                let temp = R.omit(['key', 'createtime', 'creator', 'status', 'updater', 'updatetime', 'productbranchname'])(product);
                if (R.contains(productAddTempIdPrefix)(temp.id)) {
                    temp.id = "";//去掉新增临时定义的id
                }
                orderProductDetails = R.concat(orderProductDetails, [temp]);
            }, R.isNil(dataSource.orderProductDetails) ? [] : dataSource.orderProductDetails)//去掉key
            dataSource.orderProductDetails = orderProductDetails;
            const res = yield call(createOrder, { order: dataSource });
            if (res.data.resultCode === "ok") {
                message.info("订单创建成功！");
                if (payload.onSuccess) payload.onSuccess();
            } else {
                message.error(res.data.errMessage);
                if (payload.onFail) payload.onFail();
            }
        },

        /**
         * 确认收函
         * @param payload
         * @param call
         * @param put
         * @param select
         */
        *confirmLetterById({ payload }, { call, put, select }) {
            const res = yield call(confirmLetterById, { id: payload.id, outputService: payload.url });
            if (res.data.resultCode === "ok") {
                message.info("修改成功！");
                yield put({
                    type: 'queryOrderManageList',
                    payload: R.isNil(payload.searchConditions) ? {} : payload.searchConditions
                });
            } else {
                message.error(res.data.errMessage);
            }
        },

        /**
         * 创建联系人
         * @param payload
         * @param call
         * @param put
         * @param select
         */
        *createLinkman({ payload }, { call, put, select }) {
            let state = yield select(state => state.orderManage);
            const res = yield call(createLinkman, { linkman: payload.linkman });
            let dataSource = state.dataSource;
            if (res.data.resultCode === "ok") {
                message.info("添加联系人成功!");
                dataSource.linkmanid = res.data.content.id
                yield put({
                    type: 'refreshState',
                    payload: {
                        dataSource: dataSource
                    }
                });
                yield put({
                    type: 'setLinkmanList',
                    payload: {
                        linkmanList: R.concat(state.linkmanList, [res.data.content])
                    }
                });
            } else {
                message.error(res.data.errMessage);
            }
        },

        /**
         * 新建货物存放地址
         * @param payload
         * @param call
         * @param put
         * @param select
         */
        *createAddress({ payload }, { call, put, select }) {
            let state = yield select(state => state.orderManage);
            const res = yield call(createAddress, { address: payload.address });
            let dataSource = state.dataSource;
            if (res.data.resultCode === "ok") {
                message.info("添加货物存放地址成功!");
                dataSource.addressid = res.data.content.id
                yield put({
                    type: 'refreshState',
                    payload: {
                        dataSource: dataSource
                    }
                });
                yield put({
                    type: 'setAddressList',
                    payload: {
                        addressList: R.concat(state.addressList, [res.data.content])
                    }
                });
            } else {
                message.error(res.data.errMessage);
            }
        },

        /**
         * 分页查询费用列表
         *
         * @param call
         * @param put
         * @param select
         */
        *queryOrderCost({ payload }, { call, put, select }) {
            const res = yield call(queryOrderCost, { orderId: payload.id, status: payload.status, costPage: payload.costPage });
            if (res.data.resultCode === "ok") {
                let content = res.data.content;
                let costList = R.isNil(content.list) ? [] : content.list;
                yield put({
                    type: 'setCostList',
                    payload: {
                        costList: costList,
                        costPage: R.isNil(content.page) ? Constants.DEFAULTPAGE : content.page
                    }
                });
            } else {
                message.error(res.data.errMessage);
            }
        },

        /**
         * 删除费用
         * @param payload
         * @param call
         * @param put
         * @param select
         */
        *deleteOrderCost({ payload }, { call, put, select }) {
            const res = yield call(deleteOrderCost, { id: payload.id });
            if (res.data.resultCode === "ok") {
                message.info("删除成功！");
                yield put({
                    type: "queryOrderCost",
                    payload: R.isNil(payload.searchConditions) ? {} : payload.searchConditions
                });
            } else {
                message.error(res.data.errMessage);
            }
        },

        /**
         * 更新订单
         * @param payload
         * @param call
         * @param put
         * @param select
         */
        *addOrderCost({ payload }, { call, put, select }) {
            const res = yield call(addOrderCost, { orderId: payload.id, cost: payload.cost });
            if (res.data.resultCode === "ok") {
                message.info("添加费用成功！");
                yield put({
                    type: 'queryOrderCost',
                    payload: R.isNil(payload.searchConditions) ? {} : payload.searchConditions
                });
            } else {
                message.error(res.data.errMessage);
            }
        },

        /**
         * 申报/审批 费用
         * @param payload
         * @param call
         * @param put
         * @param select
         */
        *applyOrderCost({ payload }, { call, put, select }) {
            const res = yield call(applyOrderCost, { cost: payload.cost });
            if (res.data.resultCode === "ok") {
                message.info("审批成功！");
                yield put({
                    type: "queryOrderCost",
                    payload: R.isNil(payload.searchConditions) ? {} : payload.searchConditions
                });
            } else {
                message.error(res.data.errMessage);
            }
        },


        /**
         * 确认费用收齐
         * @param payload
         * @param call
         * @param put
         * @param select
         */
        *confirmCost({ payload }, { call, put, select }) {
            const res = yield call(confirmCost, { id: payload.id, status: payload.status });
            if (res.data.resultCode === "ok") {
                message.info(payload.status === "1" ? "通关费用确认申报完毕!" : "跟单费用确认申报完毕!");
                yield put({
                    type: "queryOrderManageList",
                    payload: R.isNil(payload.searchConditions) ? {} : payload.searchConditions
                });
            } else {
                message.error(res.data.errMessage);
            }
        },

        /**
         * 查询通关专员
         *
         * @param call
         * @param put
         * @param select
         */
        *queryTgManagers({ payload }, { call, put, select }) {
            const res = yield call(queryTgManagers);
            if (res.data.resultCode === "ok") {
                let content = res.data.content;
                yield put({
                    type: 'setTgManagerList',
                    payload: {
                        tgManagerList: R.isNil(content) ? [] : content,
                    }
                });
            } else {
                message.error(res.data.errMessage);
            }
        },

        /**
         * 通关-退回订单
         * @param payload
         * @param call
         * @param put
         * @param select
         */
        *returnOrder({ payload }, { call, put, select }) {
            const res = yield call(returnOrder, { id: payload.id, gobackreason: payload.gobackreason });
            if (res.data.resultCode === "ok") {
                message.info("订单退回成功!");
                yield put({
                    type: "queryOrderManageList",
                    payload: R.isNil(payload.searchConditions) ? {} : payload.searchConditions
                });
            } else {
                message.error(res.data.errMessage);
            }
        },

        /**
         * 分页查询订单
         *
         * @param call
         * @param put
         * @param select
         */
        *getOrderCurrency2USDRate({ payload }, { call, put, select }) {
            const res = yield call(getOrderCurrency2USDRate, { ...R.omit(['onSuccess', 'onFail'])(payload) })
            if (res.data.resultCode === "ok") {
                yield put({
                    type: 'refreshState',
                    payload: {
                        usdRate: res.data.content
                    }
                });
                if (payload.onSuccess) payload.onSuccess();
            } else {
                message.error(res.data.errMessage);
                if (payload.onFail) payload.onFail();
            }
        },
        /**
         * 取消费用收齐
         */
        *cancelChargeConfirm({ payload }, { call }) {
            const res = yield call(cancelChargeConfirm, { ...R.omit(['onSuccess', 'onFail'])(payload) });
            if (res.data.resultCode === "ok") {
                message.info("取消费用收齐成功，跟单可以继续新增费用");
                if (payload.onSuccess) payload.onSuccess();
            } else {
                message.error(res.data.errMessage);
                if (payload.onFail) payload.onFail();
            }
        },

    },
    /*     subscriptions: {
            setup({ history, dispatch }) {
                return history.listen(({ pathname }) => {
                    if("/customer/customerDetails" == pathname){
                        return;
                    }
                    dispatch({
                        type: 'queryOrderManageList'
                    });
                });
            }
        } */
};